package com.acme.bankapp.domain.bank;

/**
 * Class stores client information
 * @author alex
 */
public class Client {
	private String name;
	private Gender gender;
	private Account account;
	
	/**
	 * @param name the name
	 * @param gender the gender
	 */
	public Client(String name, Gender gender) {
		this.name = name;
		this.gender = gender;
	}
	
	/**
	 * @param name the name
	 * @param gender the gender
	 * @param account the account
	 */
	public Client(String name, Gender gender, Account account) {
		this(name, gender);
		this.account = account;
	}
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * @param name the name
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * @return the gender
	 */
	public Gender getGender() {
		return gender;
	}
	
	/**
	 * @param gender the gender
	 */
	public void setGender(Gender gender) {
		this.gender = gender;
	}
	
	/**
	 * @return the account
	 */
	public Account getAccount() {
		return account;
	}
	
	/**
	 * @param account the account
	 */
	public void setAccount(Account account) {
		this.account = account;
	}
	
	/**
	 * @return the string presentation
	 */
	@Override
	public String toString() {
		return this.gender.getSalutation() + this.name + ". " + this.account;
	}
	
	/**
	 * @return the client object hash code
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((gender == null) ? 0 : gender.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}
	
	/**
	 * @param obj the client
	 * @return whether clients are equal
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Client other = (Client) obj;
		if (gender != other.gender)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
}
